package cn.hzking.gjmall.adpters.order;

import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.hzking.gjmall.R;
import cn.hzking.gjmall.bean.SureOrderBean;
import cn.hzking.gjmall.utils.PriceFormatUtils;

/**
 * Created by Administrator on 2018/4/3.
 */

public class SureOrderAdapter extends BaseQuickAdapter<SureOrderBean.DataBean.ItemHoldersBean,BaseViewHolder> {
    public SureOrderAdapter(int layoutResId, @Nullable List<SureOrderBean.DataBean.ItemHoldersBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, SureOrderBean.DataBean.ItemHoldersBean item) {
        int layoutPosition = helper.getLayoutPosition()+1;
        TextView tvName = helper.getView(R.id.name);
        TextView tvYunFei = helper.getView(R.id.yunfei);
        RecyclerView recyclerView = helper.getView(R.id.recyclerview);
        //名称
        tvName.setText("订单"+layoutPosition+"/"+item.getWarehouseShortName());
        //运费
        double freight = item.getFreight();
        String s = PriceFormatUtils.valueFormatWithTwo(String.valueOf(freight));
        tvYunFei.setText("运费¥:"+s);
        //子订单
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
        recyclerView.setLayoutManager(linearLayoutManager);
        List<SureOrderBean.DataBean.ItemHoldersBean.OrderItemsBean> orderItems = item.getOrderItems();
        SureOrderChildAdapter sureOrderChildAdapter = new SureOrderChildAdapter(R.layout.item_sure_order_gooddetail, orderItems);
        recyclerView.setAdapter(sureOrderChildAdapter);


    }
}
